﻿using System.Web.Mvc;

namespace Framework.Admin
{
    public class AdminAttribute : FilterAttribute,IAuthorizationFilter
    {
        public void OnAuthorization(AuthorizationContext filterContext)
        {
            var controller = filterContext.Controller as BaseController.BaseController;
            if (controller == null)
                return;
            if (!controller.CurrentUser.IsAdmin)
                filterContext.Result = controller.RedirectToLogin();
        }
    }
}